package com.szsfm.vehiclemanagement.manager;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.szsfm.vehiclemanagement.bean.DaoMaster;
import com.szsfm.vehiclemanagement.bean.DaoSession;
import com.szsfm.vehiclemanagement.bean.MessageDao;
import com.szsfm.vehiclemanagement.bean.PushMessageDao;
import com.szsfm.vehiclemanagement.bean.UserDao;


/**
 * Created by zhoubigbo on 2017/11/27.
 */
public class GreenDaoManager {

    private static GreenDaoManager instance;

    private DaoSession daoSession;

    public static GreenDaoManager getInstance() {
        if (instance == null) instance = new GreenDaoManager();
        return instance;
    }


    public void init(Context context) {
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, "vehicle.db", null);
        SQLiteDatabase database = helper.getWritableDatabase();
        DaoMaster daoMaster = new DaoMaster(database);
        daoSession = daoMaster.newSession();
    }


    public UserDao getUserDao() {
        return daoSession.getUserDao();
    }

    public PushMessageDao getPushMessageDao() {
        return daoSession.getPushMessageDao();
    }

    public MessageDao getMessageDao(){
        return daoSession.getMessageDao();
    }

}
